let pomelo = require("pomelo");
let pomeloLogger = require("pomelo-logger");
let path = require("path");
let accountServerInitializer = require("./app/servers/account/initializer");
let connectorServerInitializer = require("./app/servers/connector/initializer");
let gmServerInitializer = require("./app/servers/gm/initializer");
let niuniuServerInitializer = require("./app/servers/niuniu/initializer");
let zhajinhuaInitializer = require("./app/servers/zhajinhua/initializer");
let zhuojiMahjongInitializer = require("./app/servers/zhuoji/initializer");
let soloGameServerInitializer = require("./app/servers/soloGame/initializer");

let app = pomelo.createApp();

pomeloLogger.configure(path.join(app.getBase(), "/config/log4js.json"), {
    serverId : app.getServerId(),
    base : app.getBase()
});

app.configure("production|development", function () {
    app.filter(pomelo.timeout());
});

app.configure("production|development", "connector", connectorServerInitializer(app));
app.configure("production|development", "account", accountServerInitializer(app));
app.configure("production|development", "gm", gmServerInitializer(app));
app.configure("production|development", "niuniu", niuniuServerInitializer(app));
app.configure("production|development", "soloGame", soloGameServerInitializer(app));
app.configure("production|development", "zhajinhua", zhajinhuaInitializer(app));
app.configure("production|development", "zhuoji", zhuojiMahjongInitializer(app));

app.start();

process.on('uncaughtException', function(err) {
    console.error(' Caught exception: ' + err.stack);
});
